﻿using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace ShkSimulation.desktop.setting.model {
    
    public sealed class StationConfigControl : PictureBox {
        
        private StationConfigModel station;
        private ToolTip toolTip;
        private Color defaultcolor = Color.Gainsboro;
        
        private void OnMouseHover(object sender, EventArgs e) {
            toolTip.SetToolTip(this, station.ToString());
        }

        public StationConfigControl(StationConfigModel station, Point point, Bitmap bitmap, int size = 60) {
            this.station = station;
            this.Name = station.Name;
            this.Size = new Size(size, size);
            this.SizeMode = PictureBoxSizeMode.StretchImage;
            this.TabIndex = 0;
            this.TabStop = false;
            this.MouseHover += OnMouseHover;
            
            this.BackColor = defaultcolor;
            this.BackgroundImageLayout = ImageLayout.None;
            this.Location = new Point(point.X - size / 2, point.Y - size / 2);
            
            this.Image = bitmap;
            GraphicsPath gp = new GraphicsPath();
            gp.AddEllipse(this.ClientRectangle);
            this.Region = new Region(gp);
            
            toolTip = new ToolTip();
            toolTip.ToolTipTitle = station.Name;
            toolTip.AutoPopDelay = 100000;
            toolTip.InitialDelay = 50;
            toolTip.AutomaticDelay = 100000;
            toolTip.ReshowDelay = 50;
            toolTip.ShowAlways = true;
        }

        public void ResetColor() {
            this.BackColor = defaultcolor;
        }

    }
}